package com.tianqu.tms.www.car.action;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.tianqu.tms.core.base.Logger;
import com.tianqu.tms.core.base.TmsAction;
import com.tianqu.tms.core.base.UserContext;
import com.tianqu.tms.core.util.TmsConstants;
import com.tianqu.tms.entity.Codes;
import com.tianqu.tms.www.car.viewhelper.CarSeniorSearchInputViewhelper;

/**
 * 高级搜索输入页
 * 
 * @author Administrator
 *
 */
public class CarSeniorSearchInputAction extends TmsAction {
	
	private Logger logger = Logger.getLogger(CarSeniorSearchInputAction.class);


	@SuppressWarnings("unchecked")
	@Override
	protected ActionForward doAction(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response,
			UserContext uc) throws Exception {
		logger.debug(this.getClass().getName() + "#execute was called.");
		if (uc != null) {
			uc.clear();			
		}

		CarSeniorSearchInputViewhelper view = new CarSeniorSearchInputViewhelper();
		Codes code = Codes.getInstance();
		List list = code.getCodeslistByItemId(Codes.REGISTERSTATUS_TYPE);
		if(list.size() > 0){
			for(int i=0;i<list.size();i++){
				 Map map = (Map)list.get(i);
				 String str = map.get("itemCode").toString();
				 if("4".equals(str)){
					 list.remove(i);
					 break;
				 }
			}
		}
		view.setRegisterStatusList(list);
		view.setBarCodeNumList(code.getCodeslistByItemId(Codes.BARCODENUM_TYPE));
		// 去掉缓存
		if (uc.getAttribute("seniorFrom") != null) {
			uc.removeAttribute("seniorFrom");
		}
		request.setAttribute(TmsConstants.VIEWHELP, view);		
		logger.debug(this.getClass().getName() + "#execute was completed.");
		return mapping.findForward(TmsConstants.SUCCESS);
	}
}
